public class YangShi {
    public static boolean Find(int target, int [][] array) {
        int i = 0;
        int j = array[0].length - 1;
        while(i < array.length && j >= 0 ){
            if(target > array[i][j]){
                i++;
            }else if(target < array[i][j]){
                j--;
            }else{
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[][] arr = new int[4][4];
        arr= new int[][]{{1, 2, 3, 4}, {2, 3, 4, 5}, {3, 4, 5, 6}, {4, 5, 6, 7}};
        boolean res = Find(4,arr);
        System.out.println(res);
    }
}
